package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.MesSendOrderConfig;
import com.ruoyi.system.mapper.MesSendOrderConfigMapper;
import com.ruoyi.system.service.MesSendOrderConfigService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 作业票推送优先级管理(MesSendOrderConfig)表服务实现类
 *
 * @author makejava
 * @since 2023-08-03 17:19:44
 */
@Service("mesSendOrderConfigService")
public class MesSendOrderConfigServiceImpl implements MesSendOrderConfigService {
    @Resource
    private MesSendOrderConfigMapper mesSendOrderConfigDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public MesSendOrderConfig queryById(Integer id) {
        return this.mesSendOrderConfigDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param mesSendOrderConfig 筛选条件
     * @param pageRequest        分页对象
     * @return 查询结果
     */
    @Override
    public Page<MesSendOrderConfig> queryByPage(MesSendOrderConfig mesSendOrderConfig, PageRequest pageRequest) {
        long total = this.mesSendOrderConfigDao.count(mesSendOrderConfig);
        return new PageImpl<>(this.mesSendOrderConfigDao.queryAllByLimit(mesSendOrderConfig, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param mesSendOrderConfig 实例对象
     * @return 实例对象
     */
    @Override
    public MesSendOrderConfig insert(MesSendOrderConfig mesSendOrderConfig) {
        this.mesSendOrderConfigDao.insert(mesSendOrderConfig);
        return mesSendOrderConfig;
    }

    /**
     * 修改数据
     *
     * @param mesSendOrderConfig 实例对象
     * @return 实例对象
     */
    @Override
    public MesSendOrderConfig update(MesSendOrderConfig mesSendOrderConfig) {
        this.mesSendOrderConfigDao.update(mesSendOrderConfig);
        return this.queryById(mesSendOrderConfig.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.mesSendOrderConfigDao.deleteById(id) > 0;
    }
}
